import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { BaseItem } from "../../common/BaseItem";
import { ObjCreate } from "../../common/ObjCreate";
import { SmeltMaterialItemData } from "../data/SmeltMaterialItemData";
import { GameController } from "../../../mvc/GameController";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GLabel } from "../../../../../com/mui/controls/GLabel";
//class SmeltMaterialItem
    
    export  class SmeltMaterialItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            var loc1=null;
            loc1 = GlobalClass.getBitmap(ImagesConst.PackItemBg);
            loc1.x = 5;
            this.addChild(loc1);
            this._noHoleBg = GlobalClass.getBitmap(ImagesConst.NoHole);
            this._noHoleBg.x = 8;
            this._noHoleBg.y = 3;
            this.addChild(this._noHoleBg);
            this._itemImg = new BaseItem();
            this._itemImg.setSize(32, 32);
            this._itemImg.isDragAble = false;
            this._itemImg.isDropAble = false;
            this._itemImg.isThrowAble = false;
            this._itemImg.isShowLock = false;
            this._itemImg.x = loc1.x + 3;
            this._itemImg.y = loc1.y + 3;
            this.addChild(this._itemImg);
            ObjCreate.createBg(0, 42, 52, 18, this);
            this._numLabel = ObjCreate.createLabel("", 0, 42, 52, 20, flash.text.TextFormatAlign.CENTER, this, false, 16758016);
            return;
        }

        public setData(arg1: SmeltMaterialItemData): void
        {
            var loc1=0;
            var loc2=null;
            if (arg1) 
            {
                this._itemImg.itemData = arg1.itemUnBind;
                loc1 = arg1.itemAmountNeeded * GameController.smelt.currentSmeltNum;
                if (arg1.itemAmountOwn >= loc1) 
                {
                    loc2 = "#FFB500";
                }
                else 
                {
                    loc2 = "#FF0000";
                }
                this._numLabel.htmlText = HTMLUtil.addColor(String(arg1.itemAmountOwn), loc2) + HTMLUtil.addColor("/" + arg1.itemAmountNeeded, "#FFB500");
                this._noHoleBg.visible = false;
            }
            else 
            {
                this._itemImg.itemData = null;
                this._numLabel.htmlText = "";
                this._noHoleBg.visible = true;
            }
            return;
        }

        /* internal */ /* var */_itemImg: BaseItem;

        /* internal */ /* var */_numLabel: GLabel;

        /* internal */ /* var */_noHoleBg: Object /* flash.display.Bitmap */;
    }
